//
//  YHPBasicTableViewController.swift
//  SinaSwift
//
//  Created by Yan on 16/3/7.
//  Copyright © 2016年 baidu. All rights reserved.
//

import UIKit

class YHPBasicTableViewController: UITableViewController,YHPVisitorLoginViewDelegate{

    //MARK: 定义属性让子类可以调用
    let visitorLoginView : YHPVisitorLoginView = YHPVisitorLoginView()
    
    var userLogin = YHPUserAccount.shareAccount.userLogin

        //默认使用纯代码 拒绝XIB
        override func loadView() {
          
            if userLogin {
                super.loadView()
            } else {
                view = visitorLoginView
                visitorLoginView.visitorLoginViewDelegate = self
                navigationController?.navigationBar.tintColor = commonColor
                // 创建 登录rightBarButtonItem  注册leftBarButtonItem
                navigationItem.rightBarButtonItem = UIBarButtonItem(title: "注册", style: .Plain, target: self, action: "userWillRegistor")
                
                navigationItem.leftBarButtonItem = UIBarButtonItem(title: "登录", style: .Plain, target: self, action: "userWillLogin")
            }
    }
    
    //MARK: 实现代理方法
    func userWillLogin() {
        print("login")
        let oauthLogin = YHPOAuthViewController()
        let navLogin = UINavigationController(rootViewController: oauthLogin)
        presentViewController(navLogin, animated: true, completion: nil)
    }
    func userWillRegistor() {
        print("registor")
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()
    }
}
